package servlet;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.AddMasterImpl;
import model.PollUserImpl;
import bean.PollUser;
public class AddMasterServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6575508154655257827L;	
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost (request, response);
	}
	
	public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		response.setContentType("text/html");
		response.setCharacterEncoding("GBK");
		String username = request.getParameter("pmusername");
		String password = request.getParameter("pmpassword");
		String email = request.getParameter("pmemail");
		String fn = request.getParameter("pmfn");
		String ln = request.getParameter("pmln");
		
		
		PollUser user = new PollUser();
		user.setUsername(username);
		user.setPassword(password);
		user.setEmail(email);
		user.setFirstname(fn);
		user.setLastname(ln);
		AddMasterImpl addmaster = new AddMasterImpl();
		addmaster.addmaster(user);
		
		String forward;
		
			
			forward = "Masterlist.jsp";
		
		RequestDispatcher rd=request.getRequestDispatcher(forward);
		rd.forward(request, response);
	}
}
